package com.example.mydemo103.ui.rank;



import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;

import androidx.annotation.NonNull;

import androidx.fragment.app.Fragment;

import com.example.mydemo103.Adapter.ListViewAdapter;
import com.example.mydemo103.Adapter.RankListViewAdapter;
import com.example.mydemo103.R;


import com.example.mydemo103.bean.RankBook;

import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class rankFragment extends Fragment {

private LinearLayout rankfragmentbylinertlayout;
private ImageView left;
    private List<RankBook> booklist=new ArrayList<>();
    private final static String HTML_URL = "http://192.168.1.102:8080/libraryMs_war/book/book/getBooksByTitle.do?title=";
    OkHttpClient okHttpClient = new OkHttpClient();
    public RankListViewAdapter RanklistViewAdapter;
    int[] rankbookimg =new int[]{R.drawable.book13,R.drawable.book14,R.drawable.book15,R.drawable.book16,R.drawable.book17,R.drawable.book19,};
    String[] rankbooknum = new String[] {"431","423","323","312","231","145"};
    String[] rankbookid = new String[] {"4","5","6","7","8","9"};
    String[] rankbookname = new String[] {"《榫卯的魅力》","《黄帝内针讲义》","《深入理解Java虚拟机》","《实用养猪大全》","《普林斯顿微积分读本》","《吴军数学通识讲义》"};
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_rank,container,false);

        for (int i = 0; i < 6; i++) {
        String id=rankbookid[i];
        String num=rankbooknum[i];
        String name=rankbookname[i];
        int img=rankbookimg[i];
            RankBook rankBook=new RankBook(name,id,num,img);
            booklist.add(rankBook);

        }
        RanklistViewAdapter=new RankListViewAdapter(getActivity(),R.layout.rankbook_layout,booklist);
        ListView listView=view.findViewById(R.id.ranklistview);
        listView.setAdapter(RanklistViewAdapter);
        return view;
    }

}